{% extends "common/layout_main.html" %}
{% block js %}
    <script src="{{ buildStaticUrl('/js/foods/food_index.js') }}"></script>
{% endblock %}
{% block content %}
    <div class="row  border-bottom">
        <div class="col-lg-12">
            <div class="tab_title">
                <ul class="nav nav-pills">
                    <li class="current">
                        <a href="{{ buildUrl('/food/index') }}">美食列表</a>
                    </li>
                    <li>
                        <a href="{{ buildUrl('/food/cat') }}">分类列表</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <form class="form-inline wrap_search">
                <div class="row  m-t p-w-m">
                    <div class="form-group">
                        <select name="status" class="form-control inline">
                            {% if searchParams.status == -1 %}
                                <option selected="selected" value="-1">请选择状态</option>
                                <option value="1">正常</option>
                                <option value="0">已删除</option>
                            {% endif %}
                            {% if searchParams.status == 1 %}
                                <option value="-1">请选择状态</option>
                                <option selected="selected" value="1">正常</option>
                                <option value="0">已删除</option>
                            {% endif %}
                            {% if searchParams.status == 0 %}
                                <option value="-1">请选择状态</option>
                                <option value="1">正常</option>
                                <option selected="selected" value="0">已删除</option>
                            {% endif %}
                        </select>
                    </div>
                    <div class="form-group">
                        <select name="cat_id" class="form-control inline">
                            <option value="0">请选择分类</option>
                            {% for cate in cates %}
                                <option value="{{ cate.id }}">{{ cate.name }}</option>
                                {% if searchParams.cate_id == cate.id %}
                                    <option selected="selected" value="{{ cate.id }}">{{ cate.name }}</option>
                                {% endif %}
                            {% endfor %}

                        </select>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input type="text" name="mix_kw" placeholder="请输入关键字" class="form-control" value="{{ searchParams.kword }}">
                            <span class="input-group-btn">
                            <button type="button" class="btn  btn-primary search">
                                <i class="fa fa-search"></i>搜索
                            </button>
                        </span>
                        </div>
                    </div>
                </div>
                <hr>
                <div class="row">
                    <div class="col-lg-12">
                        <a class="btn btn-w-m btn-outline btn-primary pull-right" href="{{ buildUrl('/food/set') }}">
                            <i class="fa fa-plus"></i>美食
                        </a>
                    </div>
                </div>

            </form>
            <table class="table table-bordered m-t">
                <thead>
                <tr>
                    <th>美食名</th>
                    <th>分类</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>标签</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for foo in foods %}
                    <tr>
                        <td>{{ foo.name }}</td>
                        <td>
                            {% for cate in cates %}
                                {% if cate.id == foo.cat_id %}
                                    {{ cate.name }}
                                {% endif %}
                            {% endfor %}
                        </td>
                        <td>{{ foo.price }}</td>
                        <td>{{ foo.stock }}</td>
                        <td>{{ foo.tags }}</td>
                        <td>
                            <a href="{{ buildUrl('/food/info') }}?fo_id={{ foo.id }}">
                                <i class="fa fa-eye fa-lg"></i>
                            </a>
                            <a class="m-l" href="{{ buildUrl('/food/set') }}?fo_id={{ foo.id }}">
                                <i class="fa fa-edit fa-lg"></i>
                            </a>

                            <a class="m-l remove" href="{{ buildUrl('/food/delete') }}?fo_id={{ foo.id }}" data="3">
                                <i class="fa fa-trash fa-lg"></i>
                            </a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            <div class="row">
                {% include 'account/pagenation.html' %}
            </div>
        </div>
    </div>
{% endblock %}
